package controllers

import (
	beego "github.com/beego/beego/v2/server/web"
	"users/models"
)

type UserController struct {
	beego.Controller
}
type JsonR struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

func (c *UserController) Dl() {
	username := c.GetString("username")
	password := c.GetString("password")
	var s models.Users
	s.Username = username
	s.Password = password
	if username == "" || password == "" {
		c.Data["json"] = JsonR{
			Code: 500,
			Msg:  "账号跟密码不能为空",
			Data: nil,
		}
		c.ServeJSON()
		return
	}
	if s.Dl() != nil {
		c.Data["json"] = JsonR{
			Code: 500,
			Msg:  "注册失败",
			Data: nil,
		}
		c.ServeJSON()
		return
	} else {
		c.Data["json"] = JsonR{
			Code: 200,
			Msg:  "注册成功",
			Data: nil,
		}
		c.ServeJSON()
		return
	}

}
